package com.zmc.order.controller;
import com.zmc.order.application.OrderApplicationService;
import com.zmc.order.infrastructure.bean.query.ReturnApplyQuery;
import com.zmc.order.infrastructure.bean.vo.OrderReturnApplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zmc.order.infrastructure.service.OrderReturnApplyService;
import com.zmc.common.utils.R;



/**
 * 订单退货申请
 *
 * @author zmc
 * @email
 * @date 2024-10-09 14:52:02
 */
@RestController
@RequestMapping("/return/apply")
public class OrderReturnApplyController {

    @Autowired
    private OrderReturnApplyService orderReturnApplyService;

    @Autowired
    private OrderApplicationService orderApplicationService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public R list(@RequestBody ReturnApplyQuery query){
        return R.page(orderReturnApplyService.queryPage(query));
    }

    /**
     * 信息
     */
    @PostMapping("/info")
    public R info(@RequestBody OrderReturnApplyVo vo){
        return R.ok(orderReturnApplyService.getByOrderSn(vo.getOrderSn()));
    }

    /**
     * 用户申请退款
     * */
    @PostMapping("/refund")
    public R applyRefund(@RequestBody OrderReturnApplyVo vo) {
        orderApplicationService.applyRefund(vo);
        return R.ok();
    }

    /**
     * 商家审批退款
     * */
    @PostMapping("/approve")
    public R approve(@RequestBody OrderReturnApplyVo vo) {
        orderApplicationService.approveRefund(vo);
        return R.ok();
    }

}
